
/**
 *  \file l2cap_extern.h
 *
 *  This file contains extern definitions for global variables.
 */

/*
 *  Copyright (C) 2013. Mindtree Ltd.
 *  All rights reserved.
 */

#ifndef _H_L2CAP_EXTERN_
#define _H_L2CAP_EXTERN_

/* ------------------------------------------ External Global Variables */

/** Global Mutex for L2CAP Module */
BT_DEFINE_MUTEX_TYPE (extern, l2cap_mutex)

/** Common Callbacks for Ping/Echo & Information Requests */
extern L2CAP_COMMON_CB l2cap_common_cb;

/** List of Registered L2CAP PSMs (Upper Layer) */
extern L2CAP_PSM l2cap_psm_list [L2CAP_MAX_PSM];

#ifdef L2CAP_SUPPORT_CBFC_MODE

extern L2CAP_PSM_CBFC l2cap_psm_cbfc[L2CAP_MAX_CBFC_PSM];

#endif /* L2CAP_SUPPORT_CBFC_MODE */

#ifdef L2CAP_SUPPORT_ECBFC_MODE

extern L2CAP_PSM_ECBFC l2cap_psm_ecbfc[L2CAP_MAX_CBFC_PSM];

#endif /* L2CAP_SUPPORT_ECBFC_MODE */

#if ((defined L2CAP_SUPPORT_CBFC_MODE) || (defined L2CAP_SUPPORT_ECBFC_MODE))

extern L2CAP_CHANNEL_MORE_PARAM l2cap_more_channel_param[L2CAP_MAX_CHANNELS];

#endif /* L2CAP_SUPPORT_CBFC_MODE || L2CAP_SUPPORT_ECBFC_MODE */

/** The L2CAP Signalling Channel List */
extern L2CAP_SIGCH l2cap_sigch_list [BT_MAX_REMOTE_DEVICES];

/** The L2CAP Connection-oriented Channel Entities */
extern L2CAP_CE l2cap_ce_list [L2CAP_MAX_CE] ;

/** The L2CAP Command (C-Frame) Entities */
extern L2CAP_COMMAND l2cap_command_list [L2CAP_MAX_COMMANDS];

/** The L2CAP Buffer Elements */
extern L2CAP_BUFFER l2cap_buffer_list [L2CAP_MAX_BUFFER_ELEMENTS];

#ifdef L2CAP_TX_QUEUE_FLOW
/** Number of available Buffers in the L2CAP Buffer Elements */
extern UINT32 l2cap_buffer_num_available;

/** Low & High Water Marks for ACL Tx Queue Flow Control */
extern UINT32 l2cap_tx_queue_lwm;
extern UINT32 l2cap_tx_queue_hwm;

/** Flag to indicate if Flow ON/OFF has been indicated to Application */
extern UCHAR l2cap_tx_queue_flow_state;

/** Global ACL Tx Queue Flow Control Callback */
extern API_RESULT (* l2cap_tx_queue_flow_cb) (UCHAR, UINT16);
#endif /* L2CAP_TX_QUEUE_FLOW */

/**
 *  Pool of Flow Specifications used for non-default settings
 *  of the same during Configuration of Data channels
 */
extern FLOW_SPEC l2cap_flow_spec_list [L2CAP_MAX_FLOW_SPEC_BLOCKS];

/** Default Flow Specification */
extern FLOW_SPEC l2cap_default_flow_spec;

#ifdef L2CAP_EXTENDED_FLOW_SPEC
/** Default Extended Flow Specification */
extern L2CAP_EXT_FLOW_SPEC l2cap_default_ext_flow_spec;
#endif /* L2CAP_EXTENDED_FLOW_SPEC */

/**
 *  This is the timeout for a L2CAP connection entity within which
 *  configuration procedure should finish for it.
 */
extern UINT16 l2cap_config_timeout;

/**
 *  Current Signalling ID Counter Value.
 *  Each Original Command from L2CAP should go with a new Signalling ID.
 */
extern UCHAR l2cap_sig_id_counter;

/** L2CAP Signalling Command/Response Packet Handlers */
extern DECL_CONST L2CAP_SIG_HANDLER l2cap_sig_handler [L2CAP_NUM_SIG_PACKET_HANDLER];

#ifdef BT_LE
extern DECL_CONST L2CAP_SIG_HANDLER l2cap_le_sig_handler [L2CAP_NUM_LE_SIG_PACKET_HANDLER];
#endif /* BT_LE */

/** LMP Buffer Size */
extern UINT16 l2cap_lp_max_data_packets[];
extern UINT16 l2cap_lp_max_data_packet_size[];

/** Number of ACL Data Packets that can be transmitted to LMP/HCI */
extern UINT16 l2cap_lp_num_data_packets[];

extern UCHAR l2cap_link_type_based_transport_lookup[];

/** Flag for Scheduling L2CAP Data Transmission */
extern UCHAR l2cap_schedule_tx[];

/** L2CAP Transmitter Queue */
extern L2CAP_TX_Q l2cap_tx_q;

/** L2CAP Transmitter Queue - Link Type based */
extern L2CAP_TX_Q l2cap_link_type_based_tx_q[];

/** L2CAP - If separate transport for each link type */
extern UCHAR l2cap_link_type_based_transport;

#ifdef BT_ENH_L2CAP
/** Placeholder for ReqSeq for SREJ frame */
extern UCHAR l2cap_srej_req_seq;
#endif /* BT_ENH_L2CAP */

/** The L2CAP PDU currently in Transmission */
extern L2CAP_PDU l2cap_tx_pdu[];

#ifdef BT_ENH_L2CAP
/** Size of FCS field in I/S-Frame */
extern UINT16 pdu_fcs_len;
#endif /* BT_ENH_L2CAP */

#ifdef BT_L2CAP_FIXED_CHANNEL
/** Bit-map of supported fixed channels */
extern UCHAR l2cap_supp_fixed_ch_bit_map;

/** The L2CAP Fixed channel handler database */
extern L2CAP_FIXED_CHANNEL_DB l2cap_fixed_channel[L2CAP_MAX_FIXED_CHANNELS];

/** Currently used for only ATT - which can have different MTU sizes for each connection */
extern L2CAP_FIXED_CHANNEL_MORE_PARAM l2cap_fixed_channel_more_param[BT_MAX_REMOTE_DEVICES];

#endif /* BT_L2CAP_FIXED_CHANNEL */

#if ((defined L2CAP_SUPPORT_CBFC_MODE) || (defined L2CAP_SUPPORT_ECBFC_MODE))
extern L2CAP_CHANNEL l2cap_channels[L2CAP_MAX_CHANNELS];
#endif /* L2CAP_SUPPORT_CBFC_MODE || L2CAP_SUPPORT_ECBFC_MODE */

/* -------------------------------------------- Feature Specific Globals */
#ifdef L2CAP_HAVE_GROUP_SUPPORT

/** The L2CAP Group Entities */
extern L2CAP_GROUP_CE l2cap_group_ce_list [L2CAP_MAX_GROUPS_CE];

/** Connectionless L2CAP PDU for Connectionless (Group) Data */
extern L2CAP_PDU l2cap_group_rx_pdu;

/** LMP Handle for Active & Piconet Broadcast */
extern UINT16 l2cap_lp_active_bc_handle;
extern UINT16 l2cap_lp_piconet_bc_handle;

#endif /* L2CAP_HAVE_GROUP_SUPPORT */


#ifdef BT_ENH_L2CAP

/** Available I-Frame Buffer (Receive Path) */
extern L2CAP_I_FRAME_RX l2cap_i_frame_rx [L2CAP_MAX_I_FRAMES_RX];
extern UINT16 l2cap_i_frame_rx_count;

/** The L2CAP Flow & Error Control Entities */
extern L2CAP_FEC l2cap_fec_list [L2CAP_MAX_FEC_ENTITIES];

/** L2CAP Extended Feature Mask */
extern UINT32 l2cap_feature_mask;

#endif /* BT_ENH_L2CAP */

#ifdef BT_LE
/** L2CAP LE event handler callback */
extern L2CAP_LE_EVENT_HANDLER l2cap_le_event_cb;
#endif /* BT_LE */

#endif /* _H_L2CAP_EXTERN_ */

